import { request, config } from '../utils'
const { api } = config
const { pageFaqList, deleteQuestionUrl, questionDetail, addQuestionUrl, updateQuestionUrl, faqPicUploadUrl } = api

//分页查询
export async function queryFaqList(params) {
    return request({
        url: pageFaqList,
        method: 'post',
        data: params,
    })
}
//批量删除问题
export async function deleteQuestion(params) {
    return request({
        url: deleteQuestionUrl,
        method: 'post',
        data: params,
        isNotJson: true,
    })
}
//查看问题详情
export async function findQuestion(params) {
    return request({
        url: `${questionDetail}/${params.id}`,
        method: 'post',
        data: params,
        withoutToken: true,
    })
}
//添加问题
export async function addQuestion(params) {
    return request({
        url: addQuestionUrl,
        method: 'post',
        data: params,
    })
}
//修改问题
export async function updateQuestion(params) {
    return request({
        url: updateQuestionUrl,
        method: 'post',
        data: params,
    })
}
//上传图片
export async function uploadPic(params, errorCode) {
    return request({
        url: `${faqPicUploadUrl}?errorCode=${errorCode}`,
        method: 'post',
        data: params,
        withoutToken: true,
        headers: { 'content-type': 'multipart/form-data' }
    })
}
